package com.wenhuitec.productlib.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gzwh.weblib.bean.NzProductAttrModel;
import com.wenhuitec.productlib.R;
import com.wenhuitec.productlib.ui.adapter.attr.AttrPickAdapter;

import java.util.List;


public class SelectAttrView extends LinearLayout {

    private RecyclerView attrRv;
    private Context mContext;
    private AttrPickAdapter pickAdapter;

    public SelectAttrView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        LayoutInflater.from(context).inflate(R.layout.view_select_attr, this, true);
        attrRv = findViewById(R.id.attrRv);
        pickAdapter = new AttrPickAdapter(mContext);
    }

    public void setRv(NzProductAttrModel pickModelList) {
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
        layoutManager.setOrientation(RecyclerView.HORIZONTAL);
        attrRv.setLayoutManager(layoutManager);
        attrRv.setAdapter(pickAdapter);
        pickAdapter.setPickModelList(pickModelList.getAttrList());
        pickAdapter.notifyDataSetChanged();
    }

}
